package wec_wallet.ebo.com.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import android.widget.TextView;

import java.util.List;

import wec_wallet.ebo.com.R;
import wec_wallet.ebo.com.bean.InterceptDataBean;

/**
 * Created by Administrator on 2018/3/9.
 */

public class InterceptAdapter extends BaseAdapter {
    Context context;
    List<InterceptDataBean> list;
    LayoutInflater inflater;

    public InterceptAdapter(Context context, List<InterceptDataBean> list) {
        this.context = context;
        this.list = list;
        this.inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    private class ViewHolder {
        private TextView tV_name, tV_phone;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder = null;
        if (view == null) {
            holder = new ViewHolder();
            view = inflater.inflate(R.layout.acitivity_list_item_intercept, null);
            holder.tV_name = (TextView) view.findViewById(R.id.tv_item_interceptName);
            holder.tV_phone = (TextView) view.findViewById(R.id.tv_item_interceptPhone);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        holder.tV_name.setText(list.get(i).getName());
        holder.tV_phone.setText(list.get(i).getMobile());

        return view;
    }
}
